package com.firexxx.study.serialize;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.firexxx.study.util.JacksonUtil;

import java.util.ArrayList;

/**
 * TODO
 *
 * @author fireXXX
 * @date 2020/12/11 0:02
 **/
public class JsonTest {

    public static void main(String[] args) throws JsonProcessingException {
        TestModel1 testModel1 = new TestModel1();
        testModel1.setName("123");
        testModel1.setRoles(new ArrayList<>());
        testModel1.getRoles().add("123");
        testModel1.getRoles().add("456");

        TestModel testModel = new TestModel();
        testModel.setName("123");
        testModel.setRoles(new ArrayList<>());
        testModel.getRoles().add("123");
        testModel.getRoles().add("456");
        testModel.setTestModel1(testModel1);

        System.out.println(testModel);
        System.out.println(JacksonUtil.toJsonString(testModel));
    }

}